package com.qijian.maindata.domain;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.qijian.common.annotation.Excel;
import com.qijian.common.core.domain.BaseEntity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;

import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

/**
 * 工序工单对象 main_process_order
 *
 * @author qijian
 * @date 2021-10-09
 */
@EqualsAndHashCode(callSuper = true)
@Data
@ToString
@TableName("main_process_order")
public class ProcessOrder extends BaseEntity {
    private static final long serialVersionUID = 1L;

    /**
     * ID
     */
    @TableId
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "ID")
    private Long workId;

    /**
     * 关联项目
     */
    @NotNull(message = "关联项目不能为空")
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "关联项目")
    private Long projectId;

    /**
     * 用户ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "用户ID")
    private Long userId;

    @Excel(name = "工单管理人", sort = 11)
    @ApiModelProperty(value = "用户姓名")
    private String nickName;

    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "部门ID")
    private Long deptId;

    @Excel(name = "工单管理人所在车间", sort = 5)
    @ApiModelProperty(value = "部门名称")
    private String deptName;

    /**
     * 所属工位
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "所属工位")
    private Long factoryId;

    /**
     * 来源
     */
    @ApiModelProperty(value = "来源")
    private String sourceId;

    /**
     * 工单编号
     */
    @Excel(name = "工单编号", sort = 1)
    @ApiModelProperty(value = "工单编号")
    private String workCode;

    /**
     * NCR编号
     */
    @Excel(name = "NCR编号",sort = 4)
    @ApiModelProperty(value = "NCR编号")
    private String ncrCode;

    /**
     * 派工类型
     */
    @NotNull(message = "派工类型不能为空")
    @Excel(name = "派工类型", dictType = "process_order_type",sort = 3)
    @ApiModelProperty(value = "派工类型")
    private String workType;

    /**
     * 物料ID
     */
    @ApiModelProperty(value = "物料ID")
    private Long itemId;

    /**
     * 物料名称
     */
    @Excel(name = "物料名称",sort = 9)
    @ApiModelProperty(value = "物料名称")
    private String itemName;

    /**
     * 工序ID
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @ApiModelProperty(value = "工序ID")
    private Long processId;

    /**
     * 工序名称
     */
    @NotNull(message = "工序不能为空")
    @Excel(name = "工序",sort = 10)
    @ApiModelProperty(value = "工序名称")
    private String processName;

    /**
     * 数量
     */
    @NotNull(message = "数量不能为空")
    @ApiModelProperty(value = "数量")
    private Integer workNumber;

    /**
     * 工序工时
     */
    @NotNull(message = "总工价不能为空")
    @Excel(name = "工时",sort = 11)
    @ApiModelProperty(value = "工序工时")
    private BigDecimal workTime;

    /**
     * 工序工价
     */
    @NotNull(message = "总工价不能为空")
    @Excel(name = "工价",sort = 12)
    @ApiModelProperty(value = "工序工价")
    private BigDecimal workCost;

    /**
     * 已派工时
     */
    @Excel(name = "已派工时",sort = 13)
    @ApiModelProperty(value = "已派工时")
    private BigDecimal assignedCost;

    /**
     * 已派工价
     */
    @Excel(name = "已派工价",sort = 14)
    @ApiModelProperty(value = "已派工价")
    private BigDecimal assignedHour;

    /**
     * 是否开发件
     */
    @Excel(name = "是否开发件",sort = 15)
    @ApiModelProperty(value = "是否开发件")
    private Boolean isDevelop;

    /**
     * 开始时间
     */
    @NotNull(message = "开始时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "开始时间")
    private Date workStartTime;

    /**
     * 结束时间
     */
    @NotNull(message = "结束时间不能为空")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "结束时间")
    private Date workEndTime;

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @ApiModelProperty(value = "派单时间")
    private Date dispatchTime;

    /**
     * 是否外协
     */
    @ApiModelProperty(value = "是否外协")
    private Boolean isOut;

    @ApiModelProperty(value = "是否检验")
    private Boolean isCheck;

    @ApiModelProperty(value = "是否关闭")
    private Boolean isClose;

    @JsonSerialize(using = ToStringSerializer.class)
    private Long costDeptId;

    private String costDeptName;

    /**
     * 状态
     * 0 已验收
     * 1 待接单
     * 2 待报工
     * 4 待验收
     */
    @Excel(name = "状态", readConverterExp = "0=已验收,1=待接单,2=待报工,4=待验收",sort = 16)
    @ApiModelProperty(value = "状态（0-已验收，1-待接单，2-待报工，4-待验收）")
    private Integer status;

    @TableField(exist = false)
    private List<ProcessOrderUsers> users;

    @ApiModelProperty(value = "外协剩余数量")
    private Integer surplusNumber;

    @ApiModelProperty(value = "延期天数")
    private Integer delayDays;

    @ApiModelProperty(value = "工序类型名")
    private String processTypeName;

    private Integer dayQty;

    //创建工单的类型，默认1 普通工单， 2 数控件工单
    private Integer orderType;

    public static class quantityAndAmount{}
    @Deprecated
    public static class Cost{}
    public static class CostCheck{}

}
